﻿//------------------------------------------------------------------------------
// <copyright file="Slugs.cs" company="Robert MacLean">
//      Copyright © Robert MacLean.  All Rights Reserved.
// </copyright>
//
//  This code released under the terms of the 
//  Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
//------------------------------------------------------------------------------

namespace FindResultsTweak
{
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;

    class Slugs
    {
        private List<Slug> slugs = new List<Slug>() {
            new Slug() { Group = "Files", Description = "Path", Tag = "$p" },
            new Slug() { Group = "Files", Description = "Filename", Tag = "$f" },
            new Slug() { Group = "Files", Description = "Drive/UNC Share", Tag = "$v" },
            new Slug() { Group = "Files", Description = "Directory", Tag = "$d" },
            new Slug() { Group = "Files", Description = "Name", Tag = "$n" },
            new Slug() { Group = "Files", Description = "Extension", Tag = "$e" },
            new Slug() { Group = "Location", Description = "Line", Tag = "$l" },
            new Slug() { Group = "Location", Description = "Column", Tag = "$c" },
            new Slug() { Group = "Location", Description = "End column if on first line, else end of first line", Tag = "$x" },
            new Slug() { Group = "Location", Description = "Span end line", Tag = "$L" },
            new Slug() { Group = "Location", Description = "Span end column", Tag = "$C" },
            new Slug() { Group = "Text", Description = "Matched Text", Tag = "$0" },
            new Slug() { Group = "Text", Description = "Text of first line", Tag = "$t" },
            new Slug() { Group = "Text", Description = "Summary of hit", Tag = "$s" },
            new Slug() { Group = "Text", Description = "Text of spanned lines", Tag = "$T" },
            new Slug() { Group = "Char", Description = "Newline", Tag = @"\n" },
            new Slug() { Group = "Char", Description = "Space", Tag = @"\s" },
            new Slug() { Group = "Char", Description = "Tab", Tag = @"\t" },
            new Slug() { Group = "Char", Description = "Slash", Tag = @"\\" },
            new Slug() { Group = "Char", Description = "Dollar", Tag = @"\$" }
        };

        public ReadOnlyCollection<Slug> AllSlugs
        {
            get
            {
                return slugs.AsReadOnly();
            }
        }

        public ReadOnlyCollection<IGrouping<string, Slug>> GroupedSlugs
        {
            get
            {
                List<IGrouping<string, Slug>> groupedSlugs = (from s in slugs
                                                              group s by s.Group).ToList();
                return groupedSlugs.AsReadOnly();
            }
        }

        public string[] AutoCompleteSource
        {
            get
            {
                return (from s in slugs
                        select s.Tag).ToArray();
            }
        }
    }
}
